********************************************
**** GLES Short-term Campaign Panel 2017
********************************************

use "SET_YOUR_PATH_FOR_INPUT\ZA6804_en_v7-0-0.dta", clear


**************************
*** Recode Variables
**************************



**************************
*** Socio-economic problems
**************************

*personal financial situation
mvdecode  kp1_780 kp3_780 kp5_780 kp6_780 kp8_780, mv(-99/-1)

rev kp1_780, gen(ewl_2017_1)
rev kp3_780, gen(ewl_2017_3)
rev kp5_780, gen(ewl_2017_5)
rev kp6_780, gen(ewl_2017_6)
rev kp8_780, gen(ewl_2017_8)

fre ewl_2017_1-ewl_2017_8

pwcorr  ewl_2017_1-ewl_2017_8

*net household income
mvdecode kp1_2591, mv(-99/-1)
clonevar income_2017 = kp1_2591



**************************
*** Political Knowledge
**************************
/* Variables
kp1_130 kp1_110 kp1_090 kp1_090_v1  ///
kp2_3430q kp2_3430c kp2_3430l kp2_3440 kp2_3430p kp2_3430m kp2_3430r  ///
kp3_3430j kp3_3430a kp3_3430s kp3_3430t kp3_3430u kp3_3430v  ///
kp4_3430p kp4_3430m kp4_3430r kp4_3430q kp4_3430c kp4_3430l  ///
kpa1_090  kpa1_090_v1 kpa1_110 kpa1_130  ///
kp5_3430j kp5_3430a kp5_3430s kp5_3430t kp5_3430u kp5_3430v  ///
kp6_3430p kp6_3430m kp6_3430r kp6_3430q kp6_3430c kp6_3430l kp6_090 kp6_090_v1 kp6_110 kp6_130  ///
kp7_3430j kp7_3430a kp7_3430s kp7_3440 kp7_3430t kp7_3430u kp7_3430v */


*Political Knowledge: 5% clause
foreach var of varlist kp1_090_v1 kpa1_090_v1 kp6_090_v1 {
	recode `var' (1=1 "richtig")(0 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}
clonevar wissen1_2017_1 = kp1_090_v1_r
clonevar wissen1_2017_a1 = kpa1_090_v1_r
clonevar wissen1_2017_6 = kp6_090_v1_r

*Political Knowledge: first and second vote
foreach var of varlist kp1_110 kpa1_110 kp6_110 {
	recode `var' (2=1 "richtig")(1 3 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}
clonevar wissen2_2017_1 = kp1_110_r
clonevar wissen2_2017_a1 = kpa1_110_r
clonevar wissen2_2017_6 = kp6_110_r

*Political Knowledge: voting law in Germany
foreach var of varlist kp1_130 kpa1_130 kp6_130 {
	recode `var' (3=1 "richtig")(1 2 4 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}
clonevar wissen3_2017_1 = kp1_130_r
clonevar wissen3_2017_a1 = kpa1_130_r
clonevar wissen3_2017_6 = kp6_130_r

*Political Knowledge: unemployment rate
foreach var of varlist kp2_3440 kp7_3440 {
	recode `var' (2=1 "richtig")(1 3 4 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}
clonevar wissen4_2017_2 = kp2_3440_r
clonevar wissen4_2017_7 = kp7_3440_r

	
*** Pictures

***Variant 1:

*Frauke Petry
foreach var of varlist kp2_3430q kp4_3430q kp6_3430q {
	recode `var' (322=1 "richtig")(1/7 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen5_2017_2 = kp2_3430q_r
clonevar wissen5_2017_4 = kp4_3430q_r
clonevar wissen5_2017_6 = kp6_3430q_r

*Horst Seehofer	
foreach var of varlist kp2_3430c kp4_3430c kp6_3430c {
	recode `var' (3=1 "richtig")(2 4/322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen6_2017_2 = kp2_3430c_r
clonevar wissen6_2017_4 = kp4_3430c_r
clonevar wissen6_2017_6 = kp6_3430c_r

*Katrin Goering-Eckardt
foreach var of varlist kp2_3430l kp4_3430l kp6_3430l {
	recode `var' (6=1 "richtig")(2/5 7 322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen7_2017_2 = kp2_3430l_r
clonevar wissen7_2017_4 = kp4_3430l_r
clonevar wissen7_2017_6 = kp6_3430l_r

*Christian Lindner
foreach var of varlist kp2_3430p kp4_3430p kp6_3430p {
	recode `var' (5=1 "richtig")(2/4 6 7 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen8_2017_2 = kp2_3430p_r
clonevar wissen8_2017_4 = kp4_3430p_r
clonevar wissen8_2017_6 = kp6_3430p_r

*Sahra Wagenknecht
foreach var of varlist kp2_3430m kp4_3430m kp6_3430m {
	recode `var' (7=1 "richtig")(2/6 322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}				
clonevar wissen9_2017_2 = kp2_3430m_r
clonevar wissen9_2017_4 = kp4_3430m_r
clonevar wissen9_2017_6 = kp6_3430m_r

*Martin Schulz
foreach var of varlist kp2_3430r kp4_3430r kp6_3430r {
	recode `var' (4=1 "richtig")(2 3 5/7 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}		
clonevar wissen10_2017_2 = kp2_3430r_r
clonevar wissen10_2017_4 = kp4_3430r_r
clonevar wissen10_2017_6 = kp6_3430r_r

	
	
	
	
***Variant 2:
*Sigmar Gabriel
foreach var of varlist kp3_3430j kp5_3430j kp7_3430j {
	recode `var' (4=1 "richtig")(2 3 5/322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen11_2017_3 = kp3_3430j_r
clonevar wissen11_2017_5 = kp5_3430j_r
clonevar wissen11_2017_7 = kp7_3430j_r

*Angela Merkel
foreach var of varlist kp3_3430a kp5_3430a kp7_3430a  {
	recode `var' (2=1 "richtig")(3/322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen12_2017_3 = kp3_3430a_r
clonevar wissen12_2017_5 = kp5_3430a_r
clonevar wissen12_2017_7 = kp7_3430a_r

*Winfried Kretschmann
foreach var of varlist kp3_3430s kp5_3430s kp7_3430s {
	recode `var' (6=1 "richtig")(2/5 7 322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen13_2017_3 = kp3_3430s_r
clonevar wissen13_2017_5 = kp5_3430s_r
clonevar wissen13_2017_7 = kp7_3430s_r

*Wolfgang Schaeuble
foreach var of varlist kp3_3430t kp5_3430t kp7_3430t {
	recode `var' (5=1 "richtig")(2/4 6 7 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}	
clonevar wissen14_2017_3 = kp3_3430t_r
clonevar wissen14_2017_5 = kp5_3430t_r
clonevar wissen14_2017_7 = kp7_3430t_r

*Katja Kipping
foreach var of varlist kp3_3430u kp5_3430u kp7_3430u {
	recode `var' (7=1 "richtig")(2/6 322 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}				
clonevar wissen15_2017_3 = kp3_3430u_r
clonevar wissen15_2017_5 = kp5_3430u_r
clonevar wissen15_2017_7 = kp7_3430u_r

*Bjoern Hoecke
foreach var of varlist kp3_3430v kp5_3430v kp7_3430v {
	recode `var' (322=1 "richtig")(1/7 -98 -99=0 "falsch")(else=.), gen(`var'_r)
	}		
clonevar wissen16_2017_3 = kp3_3430v_r
clonevar wissen16_2017_5 = kp5_3430v_r
clonevar wissen16_2017_7 = kp7_3430v_r	
	
	
	
	
****************************
*** Knowledge indices ******
****************************

* Verbal knowledge: waves 1 & 6
gen wissen_verb_2017_1 = wissen1_2017_1 + wissen2_2017_1 + wissen3_2017_1
gen wissen_verb_2017_6 = wissen1_2017_6 + wissen2_2017_6 + wissen3_2017_6

lab var wissen_verb_2017_1 "Index: Political Knowledge, verbally 2017 (Wave 1)"
lab var wissen_verb_2017_6 "Index: Political Knowledge, verbally 2017 (Wave 6)"


* Visual knowledge: waves 2, 4 & 6
gen wissen_vis_2017_2 = wissen5_2017_2 + wissen6_2017_2 + wissen7_2017_2 + wissen8_2017_2 + wissen9_2017_2 + wissen10_2017_2
gen wissen_vis_2017_4 = wissen5_2017_4 + wissen6_2017_4 + wissen7_2017_4 + wissen8_2017_4 + wissen9_2017_4 + wissen10_2017_4
gen wissen_vis_2017_6 = wissen5_2017_6 + wissen6_2017_6 + wissen7_2017_6 + wissen8_2017_6 + wissen9_2017_6 + wissen10_2017_6

lab var wissen_vis_2017_2 "Index: Political Knowledge, visually Variant 1 2017 (Wave 2)"
lab var wissen_vis_2017_4 "Index: Political Knowledge, visually Variant 1 2017(Wave 4)"
lab var wissen_vis_2017_6 "Index: Political Knowledge, visually Variant 1 2017(Wave 6)"

	
* Visual knowledge: waves 3, 5 & 7
gen wissen_vis_2017_3 = wissen11_2017_3 + wissen12_2017_3 + wissen13_2017_3 + wissen14_2017_3 + wissen15_2017_3 + wissen16_2017_3
gen wissen_vis_2017_5 = wissen11_2017_5 + wissen12_2017_5 + wissen13_2017_5 + wissen14_2017_5 + wissen15_2017_5 + wissen16_2017_5
gen wissen_vis_2017_7 = wissen11_2017_7 + wissen12_2017_7 + wissen13_2017_7 + wissen14_2017_7 + wissen15_2017_7 + wissen16_2017_7

lab var wissen_vis_2017_3 "Index: Political Knowledge, visually Variant 2 2017(Wave 3)"
lab var wissen_vis_2017_5 "Index: Political Knowledge, visually Variant 2 2017(Wave 5)"
lab var wissen_vis_2017_7 "Index: Political Knowledge, visually Variant 2 2017(Wave 7)"

	



**************************
*** other indicators
**************************

* intention to vote
foreach num of numlist 1/9 {
	capture recode kp`num'_170 (1 6=5 "certain to vote")(2=4)(3=3)(4=2) ///
			(5=1 "certain not to vote") (else=.), gen(itv_2017_`num')
	capture lab var itv_2017_`num' "Intention to Vote (Wave `num')"		
}


* difficulty to vote
foreach num of numlist 1/9 {
	capture recode kp`num'_330 (1=5 "very difficult")(2=4)(3=3)(4=2) ///
			(5=1 "not difficult at all")(else=.), gen(vote_diff_2017_`num')
	capture lab var vote_diff_2017_`num' "Difficulty of voting decision 2017 (Wave `num')"		
}

*use internet for political issues
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_1600, mv(-99/-1)
	capture gen inet_pol_2017_`num' =  kp`num'_1600 - 1
	capture lab var inet_pol_2017_`num' "Internet use in days per week, politically current 2017 (Wave `num')"		
}

* use print media for political issues
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_1661?, mv(-99/-1)
	capture gen print_pol_bild_2017_`num' =  kp`num'_1661a - 1
	capture gen print_pol_fr_2017_`num' =  kp`num'_1661b - 1
	capture gen print_pol_faz_2017_`num' =  kp`num'_1661c - 1
	capture gen print_pol_sz_2017_`num' =  kp`num'_1661d - 1
	capture gen print_pol_taz_2017_`num' =  kp`num'_1661e - 1
	capture gen print_pol_welt_2017_`num' =  kp`num'_1661f - 1
	capture gen print_pol_other_2017_`num' =  kp`num'_1661g - 1
	capture recode kp`num'_1661h (1=1 "did not read any" 2=0 "read articles"), gen(print_pol_no_2017_`num')
	
	capture lab var print_pol_bild_2017_`num' "Print media use (BILD), politically current 2017 (Wave `num')"		
	capture lab var print_pol_fr_2017_`num' "Print media use (Frank. Rund.), politically current 2017 (Wave `num')"		
	capture lab var print_pol_faz_2017_`num' "Print media use (FAZ), politically current 2017 (Wave `num')"		
	capture lab var print_pol_sz_2017_`num' "Print media use (SZ), politically current 2017 (Wave `num')"		
	capture lab var print_pol_taz_2017_`num' "Print media use (TAZ), politically current 2017 (Wave `num')"		
	capture lab var print_pol_welt_2017_`num' "Print media use (Welt), politically current 2017 (Wave `num')"		
	capture lab var print_pol_other_2017_`num' "Print media use (other), politically current 2017 (Wave `num')"		
	capture lab var print_pol_no_2017_`num' "Print media use (none), politically current 2017 (Wave `num')"		
}


* use tv for political issues
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_1681?, mv(-99/-1)
	capture gen tv_pol_ard_2017_`num' =  kp`num'_1681a - 1
	capture gen tv_pol_zdf_2017_`num' =  kp`num'_1681b - 1
	capture gen tv_pol_rtl_2017_`num' =  kp`num'_1681c - 1
	capture gen tv_pol_sat1_2017_`num' =  kp`num'_1681d - 1
	capture gen tv_pol_other_2017_`num' =  kp`num'_1681e - 1
	capture recode kp`num'_1681f (1=1 "did not watch any" 2=0 "watched news"), gen(tv_pol_no_2017_`num')
	
	capture lab var tv_pol_ard_2017_`num' "TV media use (ARD), politically current 2017 (Wave `num')"		
	capture lab var tv_pol_zdf_2017_`num' "TV media use (ZDF), politically current 2017 (Wave `num')"		
	capture lab var tv_pol_rtl_2017_`num' "TV media use (RTL), politically current 2017 (Wave `num')"		
	capture lab var tv_pol_sat1_2017_`num' "TV media use (Sat 1), politically current 2017 (Wave `num')"		
	capture lab var tv_pol_other_2017_`num' "TV media use (other, e.g. n-tv, Pro7), politically current 2017 (Wave `num')"		
	capture lab var tv_pol_no_2017_`num' "TV media use (none), politically current 2017 (Wave `num')"		
}



* talk about politics
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_1933, mv(-99/-1)
	capture gen talk_pol_2017_`num' =  kp`num'_1933 - 1
	capture lab var talk_pol_2017_`num' "Conversations about politics in general in days per week 2017 (Wave `num')"		
}



* how often talk about politics
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_1945?, mv(-99/-1)
	capture gen talk1_2017_`num' =  kp`num'_1945a - 1
	capture gen talk2_2017_`num' =  kp`num'_1945b - 1
	capture gen talk3_2017_`num' =  kp`num'_1945c - 1

	capture lab var talk1_2017_`num' "Conversations about politics with discussion partner 1, in days per week 2017 (Wave `num')"		
	capture lab var talk2_2017_`num' "Conversations about politics with discussion partner 2, in days per week 2017 (Wave `num')"		
	capture lab var talk3_2017_`num' "Conversations about politics with discussion partner 3, in days per week 2017 (Wave `num')"		
}


* importance of election outcome
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_380, mv(-99/-1)
	capture recode kp`num'_380 (1=5 "very important")(2=4)(3=3)(4=2)(5=1 "not important at all")(else=.), gen(imp_elec_2017_`num')	
	capture lab var imp_elec_2017_`num' "Interest in the outcome of the election 2017 (Wave `num')"		
}


* Interest, election campaign
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_390, mv(-99/-1)
	capture recode kp`num'_390 (1=5 "very important")(2=4)(3=3)(4=2)(5=1 "not important at all")(else=.), gen(imp_elec_camp_2017_`num')	
	capture lab var imp_elec_camp_2017_`num' "Interest, election campaign 2017 (Wave `num')"		
}


* political interest
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_010, mv(-99/-1)
	capture recode kp`num'_010 (1=5 "very strong")(2=4)(3=3)(4=2)(5=1 "not at all")(else=.), gen(polint_2017_`num')	
	capture lab var polint_2017_`num' "Political Interest 2017 (Wave `num')"		
}



* Political Efficacy
foreach num of numlist 1/9 {
	capture mvdecode kp`num'_050a kp`num'_050e kp`num'_050h kp`num'_050k, mv(-99/-1)
	capture clonevar effint1_2017_`num' =  kp`num'_050h
	capture clonevar effint2_2017_`num' =  kp`num'_050k
	capture clonevar effex1_2017_`num' =  kp`num'_050a
	capture clonevar effex2_2017_`num' =  kp`num'_050e

	capture lab var effint1_2017_`num' "Efficacy, internal: I have the confidence to take active part in a pol. discussion 2017 (Wave `num')"		
	capture lab var effint2_2017_`num' "Efficacy, internal: I am perfectly able to understand and assess important pol. questions 2017 (Wave `num')"		
	capture lab var effex1_2017_`num' "Efficacy, external: Politicians care about what ordinary people think 2017 (Wave `num')"	
	capture lab var effex2_2017_`num' "Efficacy, external: Politicians try to get in close contact with the population 2017 (Wave `num')"		
}

* Party ID & Strength
foreach num of numlist 1/9  {
	capture recode kp`num'_2090a (1/801=1 "has PID")(808=0 "has no PID")(else=.), gen(partyid_2017_`num')
	capture gen pidstr_2017_`num' = .
	capture replace pidstr_2017_`num' = 0 if partyid_2017_`num'==0 | kp`num'_2100==99 | kp`num'_2100==100
	capture replace pidstr_2017_`num' = 1 if kp`num'_2100==5
	capture replace pidstr_2017_`num' = 2 if kp`num'_2100==4
	capture replace pidstr_2017_`num' = 3 if kp`num'_2100==3
	capture replace pidstr_2017_`num' = 4 if kp`num'_2100==2
	capture replace pidstr_2017_`num' = 5 if kp`num'_2100==1

	capture lab var partyid_2017_`num' "Has Party ID 2017 (Wave `num')"		
	capture lab var pidstr_2017_`num' "Party ID Strength 2017 (Wave `num')"		
}



*Voted: yes/no
recode kp8_180 (1 6=1 "yes")(2 -99=0 "no")(else=.), gen(vote_2017)
lab var vote_2017 "Voted in 2017"



*****************************************
*** Socio-Demographics
*****************************************

* East/West
recode ostwest (0=1 "East") (1=0 "West")(else=.), gen(east_2017)
clonevar east = east_2017

*Education
fre kp1_2320 kpa1_2320
clonevar educ_2017 = kp1_2320
replace educ_2017 = kpa1_2320 if kp1_2320<0 
recode educ_2017 (1 2=1 "low")(3=2 "medium")(4 5=3 "high")(9=.a "still student")(-95=.b "unit nonresponse"), gen (edu_2017)
lab var edu_2017 "Education (3-cat)"
clonevar edu = edu_2017

*Age
gen age_2017=(2017-kpx_2290)
lab var age_2017 "Age"
clonevar age = age_2017

*Gender
recode kpx_2280 (1=0 "male")(2=1 "female"), gen(sex_2017)
lab var sex_2017 "Gender"
clonevar sex = sex_2017

*Employment status
fre kp1_2340
clonevar empstat_2017 = kp1_2340
replace empstat_2017 = kpa1_2340 if kp1_2340<0
fre empstat_2017
lab var empstat_2017 "Employment Status"

*Unemployed
recode empstat_2017 (7=1 "unemployed")(-99/-95=.)(else=0 "not unemployed"), gen(unemployed_2017)
lab var unemployed_2017 "Unemployed"

*Not in labor force
recode empstat_2017 (3/6 10/12=1 "nlf")(-99/-95=.)(else=0 "in labor force"), gen(nlf_2017)
lab var nlf_2017 "Not in labor force"

*Occupation
fre kp1_2380
mvdecode kp1_2380, mv(-99/-1)
clonevar occupation_2017 = kp1_2380
lab var occupation_2017 "Occupation"

*Sector of the economy
fre kp1_3660
mvdecode kp1_3660, mv(-99/-1)
clonevar sector_2017 = kp1_3660
lab var sector_2017 "Job: Sector of the Economy"

*HH size
gen hhsize_2017 = kp1_2441
replace hhsize_2017 = kpa1_2441 if kp1_2441<0
mvdecode hhsize_2017, mv(-99 -95)


*Migration status
fre kpx_3930
recode kpx_3930 (-97 1=0 "no migrant")(-99 2/16=1 "migrant")(else=.), gen(migrant_2017) 

clonevar test_2017 = kpx_3930

*****************************************
*** Save data
*****************************************
gen year = 2017
gen year_2017 = 2017
clonevar lfdn_2017 = lfdn
recode lfdn13 (-97=.a "n/a"), gen(lfdn_2013)
recode lfdn09 (-97=.a "n/a"), gen(lfdn_2009)

keep year year_2017 sample wei* lfdn_2017 lfdn_2013 lfdn_2009 ewl_2017_1-sector_2017 hhsize_2017 migrant_2017 test_2017
drop kp*

save "SET_YOUR_PATH_FOR_OUTPUT\GLES\wkp2017_short.dta", replace












